﻿using Shop.RemoteModel.Coupon.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Model.Coupon;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/coupon/{name}")]
    internal class CouponApi : ApiController
    {
        private readonly ICouponService _Service;

        public CouponApi (ICouponService service)
        {
            this._Service = service;
        }

        public long Add (CouponSet data)
        {
            return this._Service.Add(data);
        }

        public void Delete ([NumValidate("shop.coupon.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }

        public bool Enable ([NumValidate("shop.coupon.id.error", 1)] long id)
        {
            return this._Service.Enable(id);
        }

        public CouponDetailed Get ([NumValidate("shop.coupon.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }

        public bool Offshelf ([NumValidate("shop.coupon.id.error", 1)] long id)
        {
            return this._Service.Offshelf(id);
        }

        public PagingResult<CouponDatum> Query (PagingParam<CouponQueryParam> param)
        {
            return this._Service.Query(param);
        }

        public bool Set (LongParam<CouponSet> set)
        {
            return this._Service.Set(set.Id, set.Value);
        }

        public bool Stop ([NumValidate("shop.coupon.id.error", 1)] long id)
        {
            return !this._Service.Stop(id);
        }
    }
}
